package test.test.one.objects;

import test.test.one.objects.tools.Speed;
import android.graphics.Bitmap;

/**
 * 
 * @author Gustavo
 * @deprecated This class was used to instance the player object
 * it has been replaced by ob_character which implements animations
 * this class is saved for reference only
 *
 */
public class ob_player extends AbstractObject{
	
	/*
	 * variables
	 */
	
	private Speed speed; //the object can move
	private ob_pickable inventory[]; //the object stores picked objects in this array
	public int item_counter; //the number of items currently on the inventory
	public boolean inventoryIsOpen; //for displaying purposes
	
	/*
	 * constructor
	 */
	
	/**
	 * basic constructor, with no inventory
	 * @param bitmap, sprite image
	 * @param x, x position
	 * @param y, y position
	 */
	public ob_player(Bitmap bitmap, int x, int y){
		super(bitmap,x,y);
		this.speed = new Speed();
		this.inventory=new ob_pickable [0];
		this.item_counter=0;
	}
	
	/**
	 * advanced constructor, with inventory
	 * @param bitmap, sprite image
	 * @param x, x position
	 * @param y, y position
	 * @param inv, the length of the inventory array
	 */
	public ob_player(Bitmap bitmap, int x, int y, int inv){
		super(bitmap,x,y);
		this.speed = new Speed();
		this.inventory=new ob_pickable [inv];
		this.item_counter=0;
		this.inventoryIsOpen=false;
	}
	
	/*
	 * get & set
	 */
	
	public ob_pickable getInventory(int pos) {
		return inventory[pos];
	}

	public void setInventory(ob_pickable item, int pos) {
		this.inventory[pos] = item;
	}
	
	public Speed getSpeed() {
		return speed;
	}

	public void setSpeed(Speed speed) {
		this.speed = speed;
	}
	
	/*
	 * methods
	 */
	
	/**
	 * this method is called whenever an item is picked
	 * @param ob, the picked item
	 */
	public void addItem(ob_pickable ob){
		inventory[item_counter]=ob;
		item_counter++;//increased
	}
	
	//TODO documentation
	public void update() {
		if (!touched) {
			x += (speed.getXv() * speed.getxDirection()); 
			y += (speed.getYv() * speed.getyDirection());
		}
	}
	
	
}
